Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.IO

Namespace C4F.DevKit.WebServicesDemo.UserControls
	Public Partial Class YouTubeControl
		Inherits UserControl
		Public Sub New()
			InitializeComponent()
		End Sub

        Private Sub YouTubeGrid_CellContentClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles YouTubeGrid.CellContentClick
            Dim Cells As DataGridViewSelectedCellCollection = YouTubeGrid.SelectedCells
            If TypeOf Cells(0) Is System.Windows.Forms.DataGridViewLinkCell Then
                Dim LinkCell As DataGridViewLinkCell = CType(Cells(0), DataGridViewLinkCell)
                Dim BrowserForm As DemoBrowser = New DemoBrowser(CStr(LinkCell.Value))
                BrowserForm.Show()
            End If
        End Sub

		Private Sub GoButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles GoButton.Click
			Try
				YouTubeService.DeveloperId = DeveloperID.Text
				YouTubeResults = YouTubeService.GetVideoListByTag_DS(SearchText.Text, 1, 10)
				YouTubeGrid.DataSource = YouTubeResults.VideoData
			Catch ex As System.Net.WebException
				Dim streamReader As StreamReader = New StreamReader(ex.Response.GetResponseStream())
				Dim responseData As String = streamReader.ReadToEnd()
				streamReader.Close()
				MessageBox.Show(responseData)
			Catch ex As Exception
				MessageBox.Show(ex.Message)
			End Try
		End Sub
	End Class
End Namespace
